//
//  OriViewController.m
//  BSProject
//
//  Created by nsm on 2019/8/24.
//  Copyright © 2019 beisheng. All rights reserved.
//

#import "OriViewController.h"
#import <YLFPopoverBackgroundView.h>

@interface OriViewController () <UIPopoverPresentationControllerDelegate>

@end

@implementation OriViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIBarButtonItem *popItem = [[UIBarButtonItem alloc] initWithTitle:@"弹框" style:UIBarButtonItemStylePlain target:self action:@selector(onClickPopItem:)];
    self.navigationItem.rightBarButtonItem = popItem;
}

- (void)onClickPopItem:(UIBarButtonItem *)sender {
    UIViewController *vc = UIViewController.new;
    vc.view.backgroundColor = UIColor.blueColor;
    vc.preferredContentSize = CGSizeMake(100, 200);
    vc.modalPresentationStyle = UIModalPresentationPopover;
    
    UIPopoverPresentationController *pv = vc.popoverPresentationController;
    pv.backgroundColor = UIColor.redColor;
    pv.popoverBackgroundViewClass = [YLFPopoverNoShadowBackgroundView class];
    pv.barButtonItem = sender;
    pv.permittedArrowDirections = UIPopoverArrowDirectionUp;
    pv.delegate = self;
    [self presentViewController:vc animated:YES completion:nil];
}

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
    return UIModalPresentationNone;
}

@end
